package com.mercury.util;

import com.mercury.filter.MercuryFilter;
import com.mercury.servlet.MercuryServlet;
import org.springframework.web.WebApplicationInitializer;

import javax.servlet.ServletRegistration.Dynamic;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;

/**
 * @author ：tx
 * 第7章
 * @description：初始化其他的servlet和filter
 * @date ：Created in 2019/2/27 9:23
 * @modified By：
 * @version:
 */
public class OtherServletInit implements WebApplicationInitializer {
    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        //绑定servlet
      /*Dynamic dynamic =  servletContext.addServlet("mercuryServlet", MercuryServlet.class);
      dynamic.addMapping("/otherServlet/*");*/

      //绑定filter
        javax.servlet.FilterRegistration.Dynamic dynamic =   servletContext.addFilter("mercuryFilter", MercuryFilter.class);
        dynamic.addMappingForUrlPatterns(null,false,"/otherFilter/*");
    }
}
